<?php

class Default_Model_Row {
	protected $_rowId;
	protected $_isActivated;
	protected $_rowNr;
	protected $_seatmap;
	protected $_position;
	protected $_xpos;
	protected $_ypos;
	
	function __construct() {
	
	}
	
	public function __set($name, $value)
    {
        $method = 'set' . $name;
        if (!method_exists($this, $method)) {
            throw new Exception('Invalid Row property');
        }
        $this->$method($value);
    }

    public function __get($name)
    {
        $method = 'get' . $name;
        if (!method_exists($this, $method)) {
            throw new Exception('Invalid Row property');
        }
        return $this->$method();
    }
    
	/**
	 * @param $_ypos the $_ypos to set
	 */
	public function setYpos($_ypos) {
		$this->_ypos = $_ypos;
	}

	/**
	 * @return the $_ypos
	 */
	public function getYpos() {
		return $this->_ypos;
	}

	/**
	 * @param $_xpos the $_xpos to set
	 */
	public function setXpos($_xpos) {
		$this->_xpos = $_xpos;
	}

	/**
	 * @return the $_xpos
	 */
	public function getXpos() {
		return $this->_xpos;
	}

	/**
	 * @param $_position the $_position to set
	 */
	public function setPosition($_position) {
		if(('horizontal' == strtolower($_position)) || ('vertical' == strtolower($_position))) {
			$this->_position = $_position;
		} else {
			throw new Exception('Invalid row position property');
		}
	}

	/**
	 * @return the $_position
	 */
	public function getPosition() {
		return $this->_position;
	}

	/**
	 * @param $_seatmap the $_seatmap to set
	 */
	public function setSeatmap($_seatmap) {
		$this->_seatmap = $_seatmap;
	}

	/**
	 * @return the $_seatmap
	 */
	public function getSeatmap() {
		return $this->_seatmap;
	}

	/**
	 * @param $_rowNr the $_rowNr to set
	 */
	public function setRowNr($_rowNr) {
		$this->_rowNr = $_rowNr;
	}

	/**
	 * @return the $_rowNr
	 */
	public function getRowNr() {
		return $this->_rowNr;
	}

	/**
	 * @param $_isActivated the $_isActivated to set
	 */
	public function setIsActivated($_isActivated) {
		if('true' == strtolower($_isActivated) || ('false' == strtolower($_isActivated))) {
			$this->_isActivated = $_isActivated;
		} else {
			throw new Exception('Invalid row position property');
		}
	}

	/**
	 * @return the $_isActivated
	 */
	public function getIsActivated() {
		return $this->_isActivated;
	}

	/**
	 * @param $_rowId the $_rowId to set
	 */
	public function setRowId($_rowId) {
		$this->_rowId = $_rowId;
	}

	/**
	 * @return the $_rowId
	 */
	public function getRowId() {
		return $this->_rowId;
	}
	
	public function setMapper($mapper)
    {
        $this->_mapper = $mapper;
        return $this;
    }

    public function getMapper()
    {
        if (null === $this->_mapper) {
            $this->setMapper(new Default_Model_RowMapper());
        }
        return $this->_mapper;
    }

    public function save()
    {
        $this->getMapper()->save($this);
    }

    public function find($id)
    {
        $this->getMapper()->find($id, $this);
        return $this;
    }

    public function fetchAll()
    {
        return $this->getMapper()->fetchAll();
    }

}

?>